class LinkNode:
    def __init__(self, data=None):
        self.data = data
        self.node = None

class LinkStack:
    def __init__(self):
        self.head = LinkNode()
        self.head.next = None
    
    def empty(self):
        if self.head.next == None:
            return True
        return False
    
    def push(self,e):#这里是头插法
        p = LinkNode(e)
        p.next = self.head.next
        self.head.next = p

    def pop(self):
        assert not self.empty()
        x = self.head.next.data
        self.head.next = self.head.next.next
        return x
    
    def gettop(self):
        assert not self.empty()
        return self.head.next.data